# -*- coding:utf-8 -*-
# Usage:   给一串数字字符串（<1000个），求这些不能组成的最小正整数
# Created by Myth on 3/22/2018.

char_num_map = {'0': 0, '1': 0, '2': 0, '3': 0, '4': 0,
                '5': 0, '6': 0, '7': 0, '8': 0, '9': 0}
number_str = input("Your number string:")
for ch in number_str:
    char_num_map[ch] += 1
# 获得数字的个数
count_list = list(char_num_map.values())

# 数目最少值
min_value = min(count_list)
# 数目最少的数字放到一个list内
min_value_index_list = []
for i in range(0, 10):
    if count_list[i] == min_value:
        min_value_index_list.append(i)

length = len(min_value_index_list)
if min_value == 0:
    if length > 1:
        if min_value_index_list[0] == 0:
            result = min_value_index_list[1]
        else:
            result = min_value_index_list[0]
    elif length == 1:
        if min_value_index_list[0] == 0:
            result = 10
        else:
            result = min_value_index_list[0]
else:
    if length > 1:
        result = ''
        if min_value_index_list[0] == 0:
            # n+1 个 min_value_index_list[1]
            for i in range(0, min_value+1):
                result += str(min_value_index_list[1])
        else:
            for i in range(0, min_value+1):
                result += str(min_value_index_list[0])
    else:
        if min_value_index_list[0] == 0:
            result = '1'
            # n+1 个 min_value_index_list[1]
            for i in range(0, min_value+1):
                result += '0'
        else:
            result = ''
            for i in range(0, min_value+1):
                result += str(min_value_index_list[0])

print(result)


